<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
<title>微信管理平台</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"></meta>
<link rel="stylesheet" href="/resource/static/css/bootstrap.min.css" ></link>
<link rel="stylesheet" href="/resource/static/css/font-awesome.min.css" ></link>
<link rel="stylesheet" href="/resource/static/css/login.min.css" ></link>
</head>
<body>
	<div class="login" id="dpLTE" v-cloak="">
		<div class="message">微信管理平台</div>
		<div id="darkbannerwrap"></div>
		<form method="post">
			<div v-if="error" class="alert alert-danger alert-dismissible">
				<h4 style="margin-bottom: 0px;font-size:13px;">
					<i class="fa fa-exclamation-triangle"></i> {{errorMsg}}
				</h4>
			</div>
			<input placeholder="用户名" v-model="username" type="text" />
			<hr class="hr15">
			<input placeholder="密码" v-model="password" type="password" v-on:keyup.13="login"/>
			<hr class="hr15">
			<input value="登录" style="width: 100%;" type="button" @click="login" v-on:keyup.13="login"/>
			<hr class="hr20">
			<!-- 帮助 <a onClick="alert('请联系管理员')">忘记密码</a> -->
		</form>
	</div>
	<div class="copyright">
		© 飞翔科技 by<a href="https://www.baidu.com/" target="_blank"> Mr.fei</a>
	</div>
	<script src="/resource/static/libs/jquery.min.js"></script>
	<script src="/resource/static/libs/jquery.md5.js"></script>
	<script src="/resource/static/libs/vue.min.js"></script>
	<script type="text/javascript">
		var vm = new Vue({
			el : '#dpLTE',
			data : {
				username : '',
				password : '',
				error : false,
				errorMsg : ''
			},
			beforeCreate : function() {
				if (self != top) {
					top.location.href = self.location.href;
				}
			},
			methods : {
				login : function(event) {
					if (vm.username == '') {
						vm.error = true;
						vm.errorMsg = '用户名为空';
						return false;
					}
					if (vm.password == '') {
						vm.error = true;
						vm.errorMsg = '密码为空';
						return false;
					}
					var data = "loginName=" + vm.username + "&password=" + $.md5(vm.password);
					$.ajax({
						type : "POST",
						url : "/admin/login/loginSubmit",
						data : data,
						dataType : "json",
						success : function(result) {
							if (result.code == 0) {//登录成功
								//localStorage.setItem("token", result.token);
								parent.location.href = '/admin/home/index';
							} else {
								vm.error = true;
								vm.errorMsg = result.message;
							}
						}
					});
				}
			}
		});
	</script>
</body>
</html>
